/**
 * @file        gpio-stm32f4xx.h
 *
 * @brief       GPIO APIs for stm32F4xx uControllers
 *
 * @date        Nov 28, 2012 11:36:20 PM
 *
 * @author      Ashwin Vijayakumar
 *
 * @copyright   (C) 2012 Ashwin Vijayakumar <ashwin@afflatustech.com>
 * @copyright   (C) 2012 Afflatus Techtronics <www.afflatustech.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 */

#ifndef GPIO_STM32F4XX_H_
#define GPIO_STM32F4XX_H_

/* ---- System headers ------------------------------------------------------ */
/* ---- Local headers ------------------------------------------------------- */
#include "stm32f4xx.h"

/* ---- Typedef section (lower_case_type) ----------------------------------- */

typedef GPIO_TypeDef            gpio_port_type;

typedef enum
{
  PIN0                          = 0x00000001,           /**< PIN0. */
  PIN1                          = 0x00000002,           /**< PIN1. */
  PIN2                          = 0x00000004,           /**< PIN2. */
  PIN3                          = 0x00000008,           /**< PIN3. */
  PIN4                          = 0x00000010,           /**< PIN4. */
  PIN5                          = 0x00000020,           /**< PIN5. */
  PIN6                          = 0x00000040,           /**< PIN6. */
  PIN7                          = 0x00000080,           /**< PIN7. */
  PIN8                          = 0x00000100,           /**< PIN8. */
  PIN9                          = 0x00000200,           /**< PIN9. */
  PIN10                         = 0x00000400,           /**< PIN10. */
  PIN11                         = 0x00000800,           /**< PIN11. */
  PIN12                         = 0x00001000,           /**< PIN12. */
  PIN13                         = 0x00002000,           /**< PIN13. */
  PIN14                         = 0x00004000,           /**< PIN14. */
  PIN15                         = 0x00008000,           /**< PIN15. */
  PIN8MSK                       = 0x000000FF,           /**< PINs 0 thru 7 */
  PIN16MSK                      = 0x0000FF00,           /**< PINs 8 thru 15 */
} gpio_pin_type;

/* ---- Constants section (ALL_CAPS) ---------------------------------------- */
/* ---- Macros section (ALL_CAPS) ------------------------------------------- */
/* ---- Global variables section (lower_case) ------------------------------- */
/* ---- Function prototypes section (lower_case) ---------------------------- */
void gpio_stm32f4xx_direction_input( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );
void gpio_stm32f4xx_direction_output( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );
int gpio_stm32f4xx_get_value( gpio_port_type* gpio_port );
void gpio_stm32f4xx_set_value( gpio_port_type* gpio_port, uint32_t value );
int gpio_stm32f4xx_get_pin( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );
void gpio_stm32f4xx_set_pin( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );
void gpio_stm32f4xx_reset_pin( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );
void gpio_stm32f4xx_toggle_pin( gpio_port_type* gpio_port, gpio_pin_type gpio_pin );

/* ---- Getter/setter method section (get/set/is_lower_case) ---------------- */

#endif /* GPIO_STM32F4XX_H_ */

/* ==== End of file ================= Copyright (C) 2012 Afflatus Techtronics */
